package cn.edu.athcm.bean;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public class TestMap {

    public static void main(String[] args) {
        Map<Integer,String> m = new HashMap<Integer,String>();
        m.put(1, "China");
        m.put(2, "India");
        m.put(3, "Japan");
        System.out.println(m);
        System.out.println(m.get(2));
        //遍历1
        System.out.println("=====1=======");
        for(int key:m.keySet()){
            System.out.println(m.get(key));
        }
        //遍历2
        System.out.println("=====2=======");
        Iterator<Integer> it = m.keySet().iterator();
        while(it.hasNext()){
            System.out.println(m.get(it.next()));
        }
        //遍历3
        System.out.println("=====3=======");
        for(Entry<Integer,String> e:m.entrySet()){
            System.out.println(e.getKey());
            System.out.println(e.getValue());
        }

    }

}
